import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ShopItemInfo } from "../../../resource/info/ShopItemInfo";
import { ItemData } from "../../../resource/info/ItemData";
import { PetMingItemData } from "../info/PetMingItemData";
import { Cache } from "../../../cache/Cache";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { PetMingBaseItem } from "./PetMingBaseItem";
import { EPlayerItemPosType } from "../../../../../Message/Public/EPlayerItemPosType";
import { MsgManager } from "../../../manager/MsgManager";
import { BuyAlert } from "../BuyAlert";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class PetMingExchangeCellRenderer
    
    export  class PetMingExchangeCellRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc3=null;
            super.data = arg1;
            this._shopItemInfo = arg1 as ShopItemInfo;
            var loc1=new ItemData(this._shopItemInfo.itemInfo.item.code);
            this._mingBaseItem.itemData = new PetMingItemData(loc1.data);
            var loc2=this._mingBaseItem.itemData as PetMingItemData;
            this._text1.text = loc2.getAttrDesc();
            var loc4;
            this._exchangeBtn.visible = loc4 = this._shopItemInfo.isCanBuy;
            this._priceText.visible = loc4;
            if (this._shopItemInfo.isCanBuy) 
            {
                this._price = this._shopItemInfo.tshopSell.price;
                this._isCanBuy = Cache.instance.role.money.brokenSoul >= this._price;
                if (this._isCanBuy) 
                {
                    this._exchangeBtn.filters = [];
                    loc3 = "#00ff00";
                }
                else 
                {
                    loc3 = "#ff0000";
                    this._exchangeBtn.filters = [FilterConst.colorFilter];
                }
                this._priceText.text = Language.getStringByParam(54942, this._price);
                this._text1.y = 6;
            }
            else 
            {
                this._text1.y = 41;
            }
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 185, 103, this);
            this._mingBaseItem = new PetMingBaseItem();
            this._mingBaseItem.x = 16;
            this._mingBaseItem.y = 15;
            this._mingBaseItem.posType = EPlayerItemPosType._EPlayerItemPosTypePetLifeStypePut;
            this._mingBaseItem.isShowLevel = true;
            this._mingBaseItem.isWordWrap = false;
            this._mingBaseItem.doubleClickEnabled = true;
            this.addChild(this._mingBaseItem);
            this._text1 = ObjCreate.createTextField("", 87, 6, 100, 18, this);
            this._text1.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._text1.multiline = true;
            this._text1.wordWrap = true;
            this._priceText = ObjCreate.createTextField("", 87, 53, 100, 18, this);
            this._exchangeBtn = ObjCreate.createGButton(Language.getString(54762), 100, 75, 60, 24, this, "ArenaRedBtn");
            this._exchangeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onExchangeBtnClickHandler);
            this._exchangeBtn.drawNow();
            return;
        }

        /* internal  */onExchangeBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            if (!this._isCanBuy) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54788));
                return;
            }
            if (this._shopItemInfo) 
            {
                BuyAlert.showByShopItemInfo(this._shopItemInfo);
            }
            return;
        }

        /* internal */ /* var */_exchangeBtn: GButton;

        /* internal */ /* var */_shopItemInfo: ShopItemInfo;

        /* internal */ /* var */_isCanBuy: Boolean;

        /* internal */ /* var */_price: int;

        /* internal */ /* var */_priceText: Object /* flash.text.TextField */;

        /* internal */ /* var */_mingBaseItem: PetMingBaseItem;

        /* internal */ /* var */_text1: Object /* flash.text.TextField */;
    }
